/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.floatwindow.floattingicon;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import com.qihoo.gamecenter.sdk.suspend.b.e.e;
import com.qihoo.gamecenter.sdk.suspend.d.b;
import java.util.ArrayList;
import java.util.List;

public class MoreMenuIconManager extends FrameLayout {
    private Context a;
    private List b = null;
    private int c = 0;
    private int d = 0;
    private int e = 0;
    private boolean f = false;
    private boolean g = false;
    private View h;
    private a i = null;
    private c j;

    public MoreMenuIconManager(Context paramContext, AttributeSet paramAttributeSet, int paramInt) {
        super(paramContext, paramAttributeSet, paramInt);
        a(paramContext);
    }

    public MoreMenuIconManager(Context paramContext, AttributeSet paramAttributeSet) {
        super(paramContext, paramAttributeSet);
        a(paramContext);
    }

    public MoreMenuIconManager(Context paramContext) {
        super(paramContext);
        a(paramContext);
    }

    protected void a(Context paramContext) {
        if (paramContext == null)
            return;
        this.a = paramContext;
    }

    public void a(a parama, List paramList, c paramc) {
        this.j = paramc;
        this.i = parama;
        if ((e.a(paramList)) || (paramList.size() <= 5))
            return;
        a(this, 0, b.i, paramList);
        a(this, 1, b.j, paramList);
        a(this, 2, b.k, paramList);
        a(this, 3, b.l, paramList);
        a(this, 4, b.m, paramList);
        this.h = findViewById(b.g);
        this.h.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                if (MoreMenuIconManager.a(MoreMenuIconManager.this) == null)
                    return;
                MoreMenuIconManager.a(MoreMenuIconManager.this).c();
            }
        });
    }

    private void a(View paramView, int paramInt1, int paramInt2, List paramList) {
        if ((paramInt1 < 0) || (paramInt1 >= 5) || (paramView == null))
            return;
        View localView = paramView.findViewById(paramInt2);
        if (localView == null)
            return;
        localView.setVisibility(8);
        if ((e.a(paramList)) || (paramInt1 + 5 >= paramList.size()))
            return;
        if (this.b == null)
            this.b = new ArrayList();
        c.a locala = (c.a) paramList.get(paramInt1 + 5);
        if (locala == null)
            return;
        f localf = new f();
        localf.a(this.a, localView, locala, this.j);
        this.b.add(localf);
    }

    public int a(int paramInt1, int paramInt2) {
        if (e.a(this.b))
            return 0;
        if (this.c == 0)
            this.c = d.b(this.a);
        this.d = paramInt1;
        this.e = paramInt2;
        return (this.c * (this.b.size() + 1));
    }

    public void a(int paramInt) {
        if ((e.a(this.b)) || (this.h == null)) {
            setVisibility(8);
            return;
        }
        FrameLayout.LayoutParams localLayoutParams = new FrameLayout.LayoutParams(this.e, this.d);
        if (paramInt == 51) {
            localLayoutParams.gravity = 51;
            localLayoutParams.leftMargin = 0;
        }
        else {
            localLayoutParams.gravity = 53;
            localLayoutParams.rightMargin = 0;
        }
        this.h.setLayoutParams(localLayoutParams);
        if ((this.f) || (this.g))
            return;
        this.f = true;
        for (int k = 0; k < this.b.size(); ++k) {
            f localf = (f) this.b.get(k);
            if (localf == null)
                continue;
            localf.b();
        }
        setVisibility(0);
    }

    public void a() {
        if (e.a(this.b)) {
            setVisibility(8);
            return;
        }
        if (!(this.f))
            return;
        int k = this.b.size();
        for (int l = 0; l < k; ++l) {
            f localf = (f) this.b.get(l);
            if (localf == null)
                continue;
            Rect localRect = localf.a();
            localRect.top = 0;
            localRect.bottom = this.d;
            localRect.left = (this.c * (k - l));
            localRect.right = (localRect.left + this.c);
            int i1 = (l + 1) * this.c + this.e / 2 - (this.c / 2);
            localf.b(localRect, i1);
        }
        this.f = false;
        invalidate();
    }

    public void b() {
        if (e.a(this.b)) {
            setVisibility(8);
            return;
        }
        if (!(this.f))
            return;
        int k = this.b.size();
        for (int l = 0; l < k; ++l) {
            f localf = (f) this.b.get(l);
            if (localf == null)
                continue;
            Rect localRect = localf.a();
            localRect.top = 0;
            localRect.bottom = this.d;
            localRect.left = (this.c * l + this.e);
            localRect.right = (localRect.left + this.c);
            localf.a(localRect, this.e / 2 - (this.c / 2));
        }
        this.f = false;
    }

    public void c() {
        setVisibility(8);
        this.g = false;
    }

    public void d() {
        if (e.a(this.b)) {
            setVisibility(8);
            return;
        }
        if ((this.f) || (this.g))
            return;
        this.g = true;
    }

    public boolean e() {
        return a(true);
    }

    public boolean f() {
        return a(false);
    }

    private boolean a(boolean paramBoolean) {
        if (e.a(this.b)) {
            setVisibility(8);
            return true;
        }
        if (!(this.g))
            return true;
        int k = 0;
        f localf;
        for (int l = 0; l < this.b.size(); ++l) {
            localf = (f) this.b.get(l);
            if (localf == null)
                continue;
            if (!(localf.d()))
                continue;
            ++k;
        }
        if (k >= this.b.size())
            this.g = false;
        else
            for (l = 0; l < this.b.size(); ++l) {
                localf = (f) this.b.get(l);
                if (localf == null)
                    continue;
                if ((this.b != null) && (localf.c() == 0) && (l == 4))
                    if (paramBoolean)
                        localf.f();
                    else
                        localf.e();
                if (localf.c() != 0)
                    continue;
                if (paramBoolean)
                    localf.f();
                else
                    localf.e();
            }
        return (!(this.g));
    }
}